<?php
/**
 * User: Administrator
 * Time: 2015/10/27 9:36
 */


function king($n, $m) {
	//生成n个数
	$list = range(1, $n);
	$i    = 1;
	while (count($list) > 1) {
		//每次循环取出一个数$val
		$val = array_shift($list);
		//当 $i 与 $m 取余不等于0时
		if (!($i % $m == 0)) {
			//把刚取出数$val放到数组末尾
			array_push($list, $val);
		}
		$i++;
	}
	//只剩一个数时返回
	return $list[0];
}

echo king(4, 3) . PHP_EOL;

$arr = array(
	array(
		'id' => 1,
		'name' => 'wanglei',
		'age'  => 18,
		'sex'  => 'man',
		'data'=>array(
			'cid'=>6
		)
	),
	array(
		'id' => 3,
		'name' => 'wanglei',
		'age'  => 18,
		'sex'  => 'man',
		'data'=>array(
			'cid'=>333
		)
	),
	array(
		'id' => 5,
		'name' => 'wanglei',
		'age'  => 18,
		'sex'  => 'man',
		'data'=>array(
			'cid'=>213
		)
	), array(
		'id' => 6,
		'name' => 'wanglei',
		'age'  => 18,
		'sex'  => 'man',
		'data'=>array(
			'cid'=>22
		)
	)
);

$ids = array_column($arr,'id');

var_dump($ids);

